import 'package:flutter/material.dart';
import 'package:flutter_xyf/pages/component/app_bar/index.dart';
import 'package:provider/provider.dart';

import 'dynamic_model.dart';
import 'first_page.dart';
// import 'first_page.dart';

class _DynamicAdd extends StatefulWidget {
  _DynamicAdd({Key? key}) : super(key: key);

  @override
  __DynamicAddState createState() => __DynamicAddState();
}

class __DynamicAddState extends State<_DynamicAdd> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final witchState = context.watch<DynamicModel>();
    final readState = context.read<DynamicModel>();
    return Scaffold(
      appBar: MyAppBar(
        title: 'ptovider Demo',
      ),
      body: FirstPage(witchState.count, readState.increment),
      // body: Text('fas'),
    );
  }
}

class ProviderDemo extends StatelessWidget {
  ProviderDemo({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider.value(
      value: DynamicModel.sharedDynamicModel,
      child: _DynamicAdd(),
    );
  }
}
